package com.by.cart.feign;

import com.by.cart.service.CartService;
import com.by.common.core.bean.ResultBean;
import com.by.common.core.response.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "购物车远程调用管理")
@RestController
@RequestMapping("/api/v1")
public class CartFeignController {

    @Autowired
    CartService cartService;


    /**
     * 获取用户选中的购物车
     * @param userId
     * @return
     */
    @Operation(summary = "获取用户选中的购物车")
    @GetMapping("/cart/getselectedcarts")
    public ResultBean getselectedcarts(@RequestParam Long userId) {
        return R.success("操作成功", cartService.getSelectedCarts(userId));
    }

    /**
     * 删除选中的购物车商品
     * @param userId
     * @param skuIds
     * @return
     */
    @Operation(summary = "删除选中的购物车商品")
    @DeleteMapping("/cart/removeSelectedCarts")
    public ResultBean removeSelectedCarts(@RequestParam Long userId, @RequestBody List<Long> skuIds) {
        cartService.removeSelectedCarts(userId,skuIds);
        return R.success("操作成功");
    }

}
